<template>
  <div>
    <h1 class="title">vue3路由</h1>
    <!-- 导航区 -->
    <div class="nav">
      <RouterLink replace to="/home" active-class="active">首页</RouterLink>
      <RouterLink replace :to="{ name: 'news' }" active-class="active"
        >新闻</RouterLink
      >
      <RouterLink replace :to="{ path: '/about' }" active-class="active"
        >关于</RouterLink
      >
      <RouterLink replace to="/props" active-class="active"
        >01_props</RouterLink
      >
      <RouterLink replace to="/event" active-class="active"
        >02_custom-event</RouterLink
      >
      <RouterLink replace to="/mitt" active-class="active">03_mitt</RouterLink>
      <RouterLink replace to="/model" active-class="active"
        >04_v-model</RouterLink
      >
      <RouterLink replace to="/attrs" active-class="active"
        >05_$attrs</RouterLink
      >
      <RouterLink replace to="/refChildParent" active-class="active"
        >06_$refs-$parent</RouterLink
      >
      <RouterLink replace to="/provideInject" active-class="active"
        >07_provide-inject</RouterLink
      >
      <RouterLink replace to="/pinia" active-class="active"
        >08_pinia</RouterLink
      >
      <RouterLink replace to="/slot" active-class="active">09_slot</RouterLink>
    </div>
    <!-- 展示区 -->
    <div class="main-content">
      <!-- 展示路由显示的内容 -->
      <RouterView></RouterView>
    </div>
  </div>
</template>

<script setup lang="ts">
import { RouterView, RouterLink } from "vue-router";
</script>
<style>
* {
  margin: 0;
  padding: 0;
}
</style>
<style lang="scss" scoped>
.title {
  margin: 0 auto;
  text-align: center;
  border: 1px solid #ccc;
  height: 100px;
  line-height: 100px;
  width: 100%;
  background: skyblue;
}
.nav {
  margin: 0 auto;
  text-align: center;
  border: 1px solid #ccc;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  a {
    padding: 20px;
    background: #ccc;
    color: #000;
    text-decoration: none;
    margin-right: 20px;
    margin-top: 10px;
    margin-bottom: 10px;
  }
  a.active {
    color: blue;
  }
}
.main-content {
  // display: flex;
  margin: 0 auto;
  height: 300px;
  text-align: left;
  color: #000;
}
</style>
